package filesearch.render

import java.awt.Component
import java.text.SimpleDateFormat

import javax.swing.JTable
import javax.swing.table.DefaultTableCellRenderer

/**
 * This render just parses the current date in millis to a 
 * more human readable format
 * 
 * @author mgg
 *
 */
class LastModifiedRenderer 
	extends DefaultTableCellRenderer{
	
	@Newify(GregorianCalendar)
	public Component getTableCellRendererComponent(JTable table, Object value,
					  boolean isSelected, boolean hasFocus, int row, int column) {
	 /* Getting the render component */
		def label = super.getTableCellRendererComponent(table, value, isSelected, hasFocus,row, column)
	 /* Parsing the date */
		label.text = 
			new SimpleDateFormat("yyyy/MM/dd").
				format(GregorianCalendar.new(timeInMillis:Number.class.cast(value).longValue()).getTime());		
		return label;
	}
}
